<template>
    <uni-popup ref="popRef" type="bottom" background-color="transparent" maskBackgroundColor="rgba(0, 0, 0, 0.6)">
        <tui-list-view unlined="all" background-color="transparent">
            <tui-list-cell v-if="$snowy.hasPerm('mobileDeviceInfoEdit')" :hover="true" :arrow="false" @click="edit" :radius="10" >
                <view class="snowy-text-center"> 编辑 </view>
            </tui-list-cell>
            <tui-list-cell v-if="$snowy.hasPerm('mobileDeviceInfoDelete')" :hover="true" :arrow="false" @click="del" :radius="10" :margin-top="2">
                <view class="snowy-text-center"> 刪除 </view>
            </tui-list-cell>
            <tui-list-cell :hover="true" :arrow="false" @click="cancel" :margin-top="10" :radius="10">
                <view class="snowy-text-center"> 取消 </view>
            </tui-list-cell>
        </tui-list-view>
    </uni-popup>
</template>
<script setup name="deviceInfoMore">
    import deviceInfoApi from '@/api/biz/device-info-api'
    import { reactive, ref, getCurrentInstance } from "vue"

    const emits = defineEmits(['handleOk'])
    const popRef = ref()
    const record = ref({})
    const open = (data) => {
    	record.value = data
    	popRef.value.open()
    }
    // 编辑
    const edit = () => {
    	uni.navigateTo({
            url: '/pages/biz/deviceinfo/form?id=' + record.value.id
    	})
    	popRef.value.close()
    }
    // 删除
    const del = () => {
    	uni.$snowy.modal.confirm(`确定要删除吗？`).then(() => {
            deviceInfoApi.deviceInfoDelete([{
                id: record.value.id
            }]).then(data => {
                emits('handleOk')
                popRef.value.close()
            })
    	})
    }
    // 取消
    const cancel = () => {
    	popRef.value.close()
    }
    defineExpose({
    	open
    })
</script>
<style lang="scss" scoped>
</style>
